<template>
  <view class="b_flower_scene_category_add_container">
    <view class="example">
      <uni-forms ref="form" :model="form" labelWidth="80px">
    <uni-forms-item label="场景名称" name="sceneName" required >
      <uni-easyinput v-model="form.sceneName" placeholder="请输入场景名称" />
    </uni-forms-item>
    <uni-forms-item label="场景图标地址" name="sceneIcon"  >
      <uni-easyinput v-model="form.sceneIcon" placeholder="请输入场景图标地址" />
    </uni-forms-item>
    <uni-forms-item label="排序" name="sort"  >
      <uni-easyinput v-model="form.sort" placeholder="请输入排序" />
    </uni-forms-item>
    <uni-forms-item label="删除标识" name="delFlag"  >
      <uni-easyinput v-model="form.delFlag" placeholder="请输入删除标识" />
    </uni-forms-item>
      </uni-forms>
      <view class="button-group">
        <button type="default" style="padding:0 3em;font-size:14px"  class="button" @click="reset">重置</button>
        <button type="primary" style="padding:0 3em;font-size:14px"  class="button" @click="submit">提交</button>
      </view>
    </view>
  </view>
</template>


<script>
    import { addCategory,getCategory,listCategory } from "@/api/category/category";
    import {getSelectDict} from "@/utils/dict";
export default {
components: {
},
data() {
  return {
    //字典类型筛选options
    form: {},
    rules: {
            sceneName: {
                rules: [{ required: true, errorMessage: "场景名称不能为空" }]
            },
    }
  }
},
onLoad(option) {
  //字典类型查询
},
onReady() {
  this.$refs.form.setRules(this.rules)
},
methods: {
  /* 提交*/
  submit() {
    console.log(this.form)
    this.$refs.form.validate().then(res => {
      addCategory(this.form).then(response => {
        this.$modal.msgSuccess("新增成功")
        setTimeout(() => {
          // 返回到上一级父页面
          this.$tab.navigateBack();
        },500)
      })
    })
  },
  /* 表单重置*/
  reset(){
    this.form = {
       id: undefined,
       sceneName: undefined,
       sceneIcon: undefined,
       sort: undefined,
       createBy: undefined,
       createTime: undefined,
       updateBy: undefined,
       updateTime: undefined,
       delFlag: undefined
    };
  }
}
}
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .b_flower_scene_category_add_container {
    .example {
      padding: 15px;
      background-color: #fff;
    }

    .button-group {
      margin-top: 15px;
      display: flex;
      justify-content: space-around;
    }
  }
</style>